﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Practices.Unity;
using System.ServiceModel;

namespace Infrastructure.Aspect.Extensions
{
    public class UnityServiceHost : ServiceHost 
    { 
        public IUnityContainer Container { set; get; } 
        public UnityServiceHost() : base() 
        { 
            
        }
        public UnityServiceHost(object singleton, params Uri[] baseAddresses)
            : base(singleton, baseAddresses)
        {
 
        }
        public UnityServiceHost(Type serviceType, params Uri[] baseAddresses) : base(serviceType, baseAddresses) 
        {            
            
        }
        public UnityServiceHost(Type serviceType)
            : base(serviceType)
        { 

        
        }

        protected override void OnOpening() 
        { 
            new UnityServiceBehavior(Container).AddToHost(this); 
            base.OnOpening(); 
        } 
    }
}
